# -*- encoding: utf-8 -*-
from flask import Flask

from config import config
from app.extensions import register_ext


def create_app(config_name='default'):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    register_ext(app)

    # 附加路由和自定义的错误页面
    from .mian import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app
